#include "Program.h"

#include <compilation/task/RenamingTask.h>


namespace compilation
{


void Program::renameSSA(void)
{
  SET_DEBUG_FOR_VISITORS();

  if (debug_instruction_visitor)
    std::cout << "renameSSA:\n"
                 "----------\n";

  RenamingAgenda::instruction_handler_visitor_type rsihv =
      RenamingAgenda::instruction_handler_visitor_type
      ::build_visitor<RenamingInstructionHandler>();

  RenamingAgenda::expression_handler_visitor_type rsehv =
      RenamingAgenda::expression_handler_visitor_type
      ::build_visitor<RenamingExpressionHandler>();

  RenamingAgenda::instruction_propagator_visitor_type rsipv =
      RenamingAgenda::instruction_propagator_visitor_type
      ::build_visitor<DefaultInstructionPropagator
      <RenamingTask, RenamingAgenda>::type>();

  for (Function const& fn : m_functions)
  {
    RenamingAgenda agenda(rsihv, rsehv, rsipv, fn);
    execute(agenda);
  }
}


} // compilation
